home *** CD-ROM | disk | FTP | other *** search
- Path: news.cencom.net!netnews
- From: wsenn@cencom.net (Will Senn)
- Newsgroups: comp.lang.c++
- Subject: cin.get() function challenge
- Date: 26 Jan 1996 16:27:40 GMT
- Organization: Your Organization
- Message-ID: <4eavds$d0u@news.cencom.net>
- NNTP-Posting-Host: macomb_ppp__05.cencom.net
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- Alrighty then!
-
- Some of you may recall my post of a week ago asking for help on getch() and
- cin. The responses I received were not encouraging.
-
- The problem:
- Write a function in C++ not using getch() that will read in ONE
- character at a time, without line buffering. In other words when the user
- presses ONE key, take and process that keypress. I had originally asked if
- it was possible to use cin or another iostream for this purpose. It would be
- nice if someone could definitively address this question.
-
- The most common reply I received and one the authors claimed would relieve all
- my problems, while implying I should read the BOOK was the following:
-
- char temp
- cin.get(temp);
- switch(temp)
- {
- case 'T':
- doSomething();
- break;
- default:
- doSomethingElse();
- }
-
- This is a piece of code that these 'programmers' obviously read in a BOOK,
- it doesn't even come close to addressing my question. If they had finished
- the chapter they were reading they might have noticed that the get() member
- function of cin is ALWAYS line buffered! Another way they might have realized
- that their answer was wrong would have been to COMPILE it.
-
- If someone out there has a grip on this rather complex issue, I would very
- much appreciate a reply, by mail or post.
-
- Thanks,
-
- Will
-
-